package kr.co.sharping.Fragment;

import java.util.Calendar;

import kr.co.sharping.R;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.RadioButton;

public class f_signup_step3 extends Fragment implements OnDateSetListener{

	private EditText name;
	private Button date_btn, next;
	private RadioButton gender_man;
	private DatePickerDialog date;
	
	private String result_name, result_gender;
	private int select_year, select_month, select_day;
	
	public f_signup_step3() {
		// TODO Auto-generated constructor stub
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		View rootView = inflater.inflate(R.layout.f_signup_step3, null);
		
		name = (EditText) rootView.findViewById(R.id.f_signup_step3_name);
		date_btn = (Button) rootView.findViewById(R.id.f_signup_step3_date_btn);
		gender_man = (RadioButton) rootView.findViewById(R.id.f_signup_step3_gender_man);
		
		return rootView;
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		
		setDatePickerDialog();
		setEvent();
	}

	private void setDatePickerDialog() {
		Calendar c = Calendar.getInstance();
		date = new DatePickerDialog(getActivity(), this, 
				c.get(Calendar.YEAR), 
				c.get(Calendar.MONTH),
				c.get(Calendar.DAY_OF_MONTH));
		
		date.setButton(getString(R.string.button_result), new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				select_year = date.getDatePicker().getYear();
				select_month = date.getDatePicker().getMonth();
				select_day = date.getDatePicker().getDayOfMonth();
				
				dialog.dismiss();
			}
		});
	}

	private void setEvent() {
		
		date_btn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				date.show();
			}
		});
	}

	@Override
	public void onDateSet(DatePicker view, int year, int monthOfYear,
			int dayOfMonth) {
		
	}
}
